<style type="text/css">
	.g_list .mytd{height:25px;}
	.title_pic{float: left;}
	.title{float:right;width:70%;}
	.text-center{font-size: 14px;}
	.zhankais{cursor: pointer;float: right;color:#f88e2d;font-size: 13px;}
	.table-bordered{border: none;}
</style>
<script type="text/javascript"> 
jQuery.fn.rowspan = function(colIdx) { //封装的一个JQuery小插件  
return this.each(function(){ 
var that; 
$('tr', this).each(function(row) { 
$('td:eq('+colIdx+')', this).filter(':visible').each(function(col) { 
if (that!=null && $(this).html() == $(that).html()) { 
rowspan = $(that).attr("rowSpan"); 
if (rowspan == undefined) { 
$(that).attr("rowSpan",1); 
rowspan = $(that).attr("rowSpan"); } 
rowspan = Number(rowspan)+1; 
$(that).attr("rowSpan",rowspan); 
$(this).hide(); 
} else { 
that = this; 
} 
}); 
}); 
}); 
}

$(function() {
	$(".g_list").rowspan(4);
	$(".g_list").rowspan(5);
	
$(".zhankais").click(function(){
	var pd=$(this).text();
	var myrel=$(this).attr('rel');
	if(pd=='收回明细'){
		$(this).text('展开明细');
		$(this).removeClass('glyphicon-chevron-up');
		$(this).addClass('glyphicon-chevron-down');
		
	}else{
		$(this).removeClass('glyphicon-chevron-down');
		$(this).addClass('glyphicon-chevron-up');
		$(this).text('收回明细');
	}
	$(".zhankai"+myrel).slideToggle();
	}); 
	
$(".table-responsive #look_biaoqian").click(function(){
	var order_id=$(this).attr('rel');
	$.getJSON('/index.php/Admin/Order/look_biaoqian/order_id/'+order_id+'?v='+new Date, function(json){
	  layer.photos({
		photos: json //格式见API文档手册页
		,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
	  });
	});
	});	
	
	
}); 

</script>
             <form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
                <div class="table-responsive">
                    <table class="table table-bordered" style="font-size:13px;">
                                <tbody>
								<tr >
									<div class="navbar-form form-inline">
										全选
										<input type="checkbox" onclick="$('input[name=\'allorder_id\[\]\']').prop('checked', this.checked);">
										<button id="act_button" type="button" onclick="act_edit_driver();" class="btn btn-primary" style="margin-left:15px;"><i class="fa"></i> 批量修改司机</button>
										<button id="act_button" type="button" onclick="act_edit_delivery();" class="btn btn-primary" style="margin-left:15px;"><i class="fa"></i> 批量修改到货</button>
										<?php
										if(session('role_id')==1 || session('role_id')==20|| session('role_id')==15 ){
									   ?>
										<button id="act_button" type="button" onclick="act_edit_notchuku();" class="btn btn-primary" style="margin-left:15px;"><i class="fa"></i> 批量修改不出库</button>
										<?php
									   }
									   ?>
									</div>
								
									<div style="color: #f00;font-weight: bold;font-size: 20px;margin-right: 50px;text-align: right;margin-bottom: 20px">司机应收总金额：￥{$siji_heji}</div>
								</tr>
                                <volist name="orderList" id="list">
                                 <tr>
                                     <td class="text-right" style="background:#e2e8ff;">
										 <input type="checkbox" name="allorder_id[]" title="批量打印" value="{$list.order_id}"><input type="hidden" name="order_ids" value="{$list.order_ids}">
                                 		单号：{$list.order_sn}
                                     </td>
                                     <td class="text-center" style="background:#e2e8ff;">客户名：{$list.company}<if condition="$list['is_cod'] eq '1'"><span style="color: red">(货到付款)</span></if></td>
                                     <td class="text-center" style="background:#e2e8ff;">标识/线路：{$list.biaoshi}/{$list.biaoshi_xian}</td>
                                     
                                     <td class="text-center" style="background:#e2e8ff;color:green;">司机：{$list.nick_name}</td>
                                 	<td class="text-center" style="background:#e2e8ff;color: #f88e2d;"></td>
									<td class="text-center" style="background:#e2e8ff;">出库时间：{$list.shijian}</td>
									
								    <td class="text-center" style="background:#e2e8ff;">
								        <if condition='$list.driver_time eq "" '>
								            <a href="javascript:;" onclick="confirmDelivery({$list.order_id})" data-toggle="tooltip" title="" class="btn btn-info">  确认到货</a>
								        </if>
							        </td>
								    
                                 </tr>
<tr class="zhankai{$list.order_id}">
	<td class="text-center" colspan="12" style="padding:0;border: none;">
<table class="table table-bordered g_list" style="font-size:13px;width:100%;background:#f6fdff;">
<tr>
		<td width="200" class="mytd">产品名</td>
		<td width="110" class="mytd">单价</td> 
		<td width="90" class="mytd">数量</td>
		<td width="90" class="mytd">小计</td>
		<td width="120" class="mytd">收件人</td>
		<td width="120" class="mytd">联系方式</td>
</tr>
<?php
$points_count=0; 
?>
<volist name="list.g_list" id="lists">
	<?php
	$lists['member_goods_price']=$lists['member_goods_price']+$lists['yijia'];
	$points_count+=$lists['member_goods_price']*$lists['goods_num'];
	$huodong=$lists['prom_id']!=0 ? ' <span style="color:red">活动价</span>' : '';
	?>
	<tr>
		<td style="text-align:left;">
			<img src="{$lists.original_img}" height="50" width="50" class="title_pic" onmouseover="layer.tips('<img src={$lists.original_img} width=180>',this,{tips: [1, '#e2e8ff']});" onmouseout="layer.closeAll();">
			<div class="title">{$lists.goods_name} {$huodong}</div>
			<div class="title" style="color:#8e8a8a;">{$lists.spec_key_name}</div>
			</td>
		<td class="mytd">￥{$lists.member_goods_price}</td> 
		<td class="mytd">{$lists.goods_num}</td>
		<td class="mytd">{$lists['member_goods_price']*$lists['goods_num']}</td>
		<td class="mytd">{$list.consignee}（{$list.company}）<if condition="($list[rpay]==1) AND ($list[rpay_store] == $list[a_store_id]) "><span style="color: red">（预付款）</span></if> </td>
		<td class="mytd">{$list.company_address}，{$list.mobile}</td>
	</tr>
</volist>
<tr>
	<td class="text-right" colspan="3" style="font-weight: bold;font-size:16px;text-align: right;height: 45px;">优惠券金额：</td>
	<td class="text-center" style="color: red;font-weight: bold;">￥{:sanwei($list['coupon_price'])}</td>
	<td class="text-right"  style="font-weight: bold;font-size:16px;text-align: right;height: 45px;">应收总金额：</td>
	<td class="text-center" style="color: red;font-weight: bold;">￥{:sanwei($points_count-$list['coupon_price'])}</td>
	</tr>
<tr>
	<td class="text-center" colspan="3" style="">
		<b>平台改单：</b>
					<if condition="$list.admin_note eq ''">
							<span style="color:#999;">未改单</span>
					<else/>
							<span style="color:red;">改价：<b>￥{$list.discount}</b>，{$list.admin_note|htmlspecialchars_decode}</span>
					</if>
	</td>
	<td class="text-center" colspan="1" style="color:green;">入库：（{$list.ruku}件）</td>
    <td class="text-center" colspan="1" style="color:red;">发货：（{$list.chuku}件）</td>
	<td class="text-center" colspan="1" id="look_biaoqian" rel="{$list.order_id}" style="cursor: pointer;" title="点击查看标签">
		标签数<span style="color:#f88e2d;">（查看）</span>：<b style="color: red;">{$list.jian_count}</b>
	</td>
</tr>
</table>
	</td>
</tr>

                                </volist>
                                </tbody>
                            </table>
                        </div>
                    </form>
                    <div class="row">
                        <div class="col-sm-5">{$page}</div>
                        <div class="col-sm-7"></div>
                    </div>
<script>
    $(".pagination  a").click(function(){
        var page = $(this).data('p');
        var number = $(this).data('n');
        ajax_get_table('search-form2',page,number);
    });

    $(".page_num").change(function (){
    	var number = $(this).val();
		ajax_get_table('search-form2',1,number);
	})

	function get_select_order_id_str() {
		if ($('input[name="allorder_id\[\]"]:checked').length == 0)
			return false;
		var goods_arr = Array();
		$('input[name="allorder_id\[\]"]:checked').each(function () {
			goods_arr.push($(this).val());
		});
		var order_id_str = goods_arr.join(',');
		return order_id_str
	}
    
    function confirmDelivery(order_id){
    	layer.confirm('您确认到货吗？', {
			btn: ['确定','取消'] //按钮
		}, function(cindex){
			$.ajax({
					type:'post',
					url:"{:U('Admin/order/confirmDelivery')}",
					data:{order_id:order_id},
					success:function(res){
					    
				// 		layer.close(index);
						if(res){
				// 			let data = JSON.parse(res);
							if(res.status){
								layer.msg(res.msg, {icon:6},function(){
									ajax_get_table('search-form2',1,0)
								});
							}else{
								layer.msg(res.msg, {icon:5},function(){});
							}

						}
					}
				});
		})
    }
    
      
	function act_edit_delivery(order_id){
		var ids = get_select_order_id_str();
		if (ids == false) {
			layer.alert('请勾选要操作的订单', {icon: 2});
			return;
		}
		layer.confirm('您确认要一键修改到货吗？', {
			btn: ['确定','取消'] //按钮
		}, function(cindex){
			layer.close(cindex);
				$.ajax({
					type:'post',
					url:"{:U('Admin/order/batch_edit_delivery')}",
					data:{order_id:ids},
					success:function(res){
						if(res){
							if(res.status){
								layer.msg(res.msg, {icon:6},function(){
									ajax_get_table('search-form2',1,0)
								});
							}else{
								layer.msg(res.msg, {icon:5},function(){});
							}

						}
					}
				});
		})

	}
	function act_edit_driver(order_id){
		var ids = get_select_order_id_str();
		if (ids == false) {
			layer.alert('请勾选要操作的订单', {icon: 2});
			return;
		}
		layer.confirm('您确认要一键修改司机吗？', {
			btn: ['确定','取消'] //按钮
		}, function(cindex){
			layer.close(cindex);
			layer.prompt({
				formType: 2,
				title: '请输入司机全名',
			}, function(value, index, elem){
				$.ajax({
					type:'post',
					url:"{:U('Admin/order/batch_edit_driver')}",
					data:{order_id:ids,driver_name:value},
					success:function(res){
						layer.close(index);
						if(res){
							let data = JSON.parse(res);
							if(data.status){
								layer.msg(data.msg, {icon:6},function(){
									ajax_get_table('search-form2',1,0)
								});
							}else{
								layer.msg(data.msg, {icon:5},function(){});
							}

						}
					}
				});
			});
		})

	}
	
		function act_edit_notchuku(order_id){
		var ids = get_select_order_id_str();
		if (ids == false) {
			layer.alert('请勾选要操作的订单', {icon: 2});
			return;
		}
		layer.confirm('您确认要一键修改为不出库吗？', {
			btn: ['确定','取消'] //按钮
		}, function(cindex){
			layer.close(cindex);
			$.ajax({
					type:'post',
					url:"{:U('Admin/order/act_edit_notchuku')}",
					data:{order_id:ids},
					success:function(res){
						layer.close(cindex);
						if(res){
							let data = JSON.parse(res);
							if(data.status){
								layer.msg(data.msg, {icon:6},function(){
									ajax_get_table('search-form2',1,0)
								});
							}else{
								layer.msg(data.msg, {icon:5},function(){});
							}

						}
					}
				});
		})

	}
</script>